package com.ashlikun.flutter_base_app.pigeons

import CommonParams
import MessageFlutterApi
import MessageHostApi
import io.flutter.embedding.engine.FlutterEngine

/**
 * 作者　　: 李坤
 * 创建时间: 2025/2/12　15:57
 * 邮箱　　：496546144@qq.com
 *
 * 功能介绍：原生交互工具
 */
object PigeonsConfig {
    //负责调用flutter的api
    lateinit var api: MessageFlutterApi
    fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        MessageHostApi.setUp(flutterEngine.dartExecutor.binaryMessenger, AppMessageHostApi())
        api = MessageFlutterApi(flutterEngine.dartExecutor.binaryMessenger)
    }

    fun apiCall(params: CommonParams, callback: (Result<CommonParams>) -> Unit) {
        api.call(params, callback)
    }
}